package Package2;

import java.util.Random;

public class isLight {
    public static void main(String[] args) {
        /*boolean isLightGreen = false;
        boolean isLightYellow = false;
        boolean isLightRed = true;
        if(isLightGreen){
            System.out.println("GoGoGo!!!");
        }

        if(isLightYellow){
            System.out.println("Slow!!!");
        }

        if(isLightRed){
            System.out.println("Stop!!!");
        }*/

        /*Scanner sc = new Scanner(System.in);
        int money = sc.nextInt();
        if(money >= 100){
            System.out.println("去网红餐厅！！！");
        }else{
            System.out.println("去沙县小吃！！！");
        }*/

        /*Scanner sc = new Scanner(System.in);
        System.out.println("请输入今天星期几：");
        int day = sc.nextInt();
        switch(day){
            case 1:
                System.out.println("跑步！！");
                break;
            case 2:
                System.out.println("游泳！！");
                break;
            case 3:
                System.out.println("慢走！！");
                break;
            case 4:
                System.out.println("动感单车！！");
                break;
            case 5:
                System.out.println("拳击！！");
                break;
            case 6:
                System.out.println("爬山！！");
                break;
            case 7:
                System.out.println("好好吃一顿！！");
                break;
            default:
                System.out.println("输入错误！！");
                break;
        }*/

        /*Scanner sc = new Scanner(System.in);
        System.out.println("请输入今天星期几：");
        int day = sc.nextInt();
        switch(day) {
            case 1 -> System.out.println("跑步！！");
            case 2 -> System.out.println("游泳！！");
            case 3 ->  System.out.println("慢走！！");
            case 4 ->  System.out.println("动感单车！！");
            case 5 ->  System.out.println("拳击！！");
            case 6 ->System.out.println("爬山！！");
            case 7 -> System.out.println("好好吃一顿！！");
            default -> System.out.println("输入错误！！");
        }*/

        /*Scanner sc = new Scanner(System.in);
        System.out.println("请输入星期：");
        int week = sc.nextInt();
        switch (week) {
            case 1, 2, 3, 4, 5 -> System.out.println("工作日！");
            case 6, 7 -> System.out.println("休息日！");
            default -> System.out.println("输入错误！");
        }*/

        /*Scanner sc = new Scanner(System.in);
        System.out.println("请输入哟一个数字代表开始：");
        int start = sc.nextInt();
        System.out.println("亲输入一个数字代表结束：");
        int count = 0;
        int end = sc.nextInt();
        for (int i = start; i <= end; i++) {
            if (i % 3 == 0 && i % 5 == 0) {
                ++count;
                System.out.println(i);
            }
        }
        System.out.println(count);*/

        /*int i = 0;
        while (i++ < 100) {
            System.out.println(i);
        }*/

      /*  int count = 0;
        double d_num = 0.1;
        while (d_num <= 8844430) {
            d_num *= 2;
            ++count;
        }
        System.out.println(count);*/

       /* //判断一个数字是否是回文数字
        int num1 = 121;
        int temp = num1;//临时变量，记录num1
        int num2 = 0;//反转之后的数字
        while(temp != 0) {
            int ge = temp % 10;
            num2 = num2 * 10 + ge;
            temp /= 10;
        }
        System.out.println(num1 == num2)；*/

      /*  int x = 12321;
        int temp = x;
        int num = 0;
        while (temp != 0) {
            int ge = temp % 10;
            num = num * 10 + ge;
            temp /= 10;
        }
        System.out.println(x);
        System.out.println(num);
        System.out.println(x == num);*/

        //不使用除法和取模，求两个数的上和余数
        /*int divided = 108;
        int divisor = 10;
        int count = 0;
        while (divided >= divisor) {
            divided -= divisor;
            ++count;
        }
        System.out.println("商为：" + count);
        System.out.println("余数为：" + divided);*/

        //逢7过
       /* for (int i = 1; i <= 100; i++) {
            if (i % 10 == 7 || i / 10 % 10 == 7 || i % 7 == 0) {
                System.out.println("过");
                continue;
            }
            System.out.println(i);
        }*/

        //平方根
        /*Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int i = 1;
        while (i*i < x) {
            ++i;
        }
        System.out.println("x的平方根是:" + (i - 1));
        for (int i = 1; i <= x; i++) {
            if (i * i == x) {
                System.out.println(i + "就是" + x + "的平方根");
                break;
            } else if (i * i > x) {
                System.out.println((i - 1) + "是" + x + "平方根的整数部分");
                break;
            }
        }*/

        //判断一个数是否是素数
        /*Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数：");
        int x = sc.nextInt();
        //2 --- x - 1
        boolean flag = true;
        for (int i = 2; i < x; ++i) {//算法优化--- i <= sqrt(x)
            if (x % i == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println(x + "是素数");
        } else {
            System.out.println(x + "不是素数");
        }*/


        //猜数字
      /*  Random r = new Random();
        //生成 1~100 之间的随机数
        int x = r.nextInt(100) + 1;
        Scanner sc = new Scanner(System.in);
        System.out.println("请猜数字：");
        while (true) {
            int num = sc.nextInt();
            if (num == x) {
                System.out.println("恭喜你猜对了");
                break;
            } else if (num < x) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜大了");
            }
        }*/

        //-------数组的静态初始化-------
        // 数组一但定义，长度就无法改变。
       /* int[] arr1 = new int[]{1, 2, 3, 4, 5, 6};//完整版定义及其初始化
        int[] arr2 = {2, 3, 4, 65, 7};//数组的简化定义

        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }*/

        /*int[] arr3 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr3[i] % 3 == 0) {
                ++count;
            }
        }
        System.out.println(count);*/

        //奇数扩2倍，偶数缩2倍
       /* int[] arr4 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i = 0; i < arr4.length; ++i) {
            if (arr4[i] % 2 == 1) {
                arr4[i] *= 2;
            } else {
                arr4[i] /= 2;
            }
        }
        for (int i = 0; i < arr4.length; i++) {
            System.out.println(arr4[i]);
        }*/

        //------数组的动态初始化------
        //数据类型[] 数组名 = new 数据类型[数组长度]
        //int[] arr = new int[3]

        //打擂台求最大值
        /*int[] arr5 = {11,22,66,44,37,45};
        int max = arr5[0];
        for (int i = 1; i < arr5.length; i++) {
            if(arr5[i] > max){
                max = arr5[i];
            }
        }
        System.out.println("最大值是：" + max);*/

        //生成10个 1--100 之间的随机数存入数组
       /* Random r = new Random();
        int[] arr6 = new int[10];
        for (int i = 0; i < arr6.length; i++) {
            arr6[i] = r.nextInt(100) + 1;
            System.out.println(arr6[i]);
        }

        int sum = 0;
        for (int i = 0; i < arr6.length; i++) {
            sum += arr6[i];
        }
        System.out.println("所有数据的和为：" + sum);

        int average = sum / arr6.length;
        System.out.println("平均数为：" + average);

        int count = 0;
        for (int i = 0; i < arr6.length; i++) {
            if (arr6[i] < average) {
                ++count;
            }
        }
        System.out.println("有" + count + "个数据比平均数小");*/

        //数组元素逆置
        /*int[] arr7 = new int[]{1, 2, 3, 4, 5, 6, 7};
        for (int i = 0, j = arr7.length - 1; i < j; i++, j--) {
            int temp = arr7[i];
            arr7[i] = arr7[j];
            arr7[j] = temp;
        }
        for (int i = 0; i < arr7.length; i++) {
            System.out.print(arr7[i] + "\t");
        }*/

        //打乱数组中的顺序
        int[] arr8 = new int[]{1, 2, 3, 4, 5, 6, 7};
        System.out.println("打乱前数组为：");
        for (int i = 0; i < arr8.length; i++) {
            System.out.print(arr8[i] + "\t");
        }
        Random r = new Random();
        for (int i = 0; i < arr8.length; i++) {
            int index = r.nextInt(arr8.length);//------随机数与 arr8 的下标 arr8.length 对应
            int temp = arr8[i];
            arr8[i] = arr8[index];
            arr8[index] = temp;
        }
        System.out.println("\n打乱后数组为：");
        for (int i = 0; i < arr8.length; i++) {
            System.out.print(arr8[i] + "\t");
        }

    }
}